
template <typename T>
class seqStack
{
public:
    seqStack(int size = 10) : size_(size), top_(0), stack_(new T[size]) {}
    seqStack(seqStack<T>& stack)
    {
        this->size_ = stack.size_;
        this->top_ = stack.top_;
        delete[] this->stack_;

        this->stack_ = new T[this->size_];
        for (int i = 0; i < this->size_; i++)
        {
            stack_[i] = stack.stack_[i];
        }
    }

    seqStack<T> &operator=(seqStack<T> stack)
    {
        if (this == stack)
        {
            return *this;
        }
        this->size_ = stack.size_;
        this->top_ = stack.top_;
        delete[] this->stack_;

        this->stack_ = new T[this->size_];
        for (int i = 0; i < this->size_; i++)
        {
            stack_[i] = stack.stack_[i];
        }
    }

    bool full()
    {
        return this->size_ == this->top_;
    }
    bool empty()
    {
        return this->top_ == 0;
    }
    T top()
    {
        return this->stack_[this->top_ - 1];
    }
    void pop()
    {
        if(this->empty()) {
            return;
        }
        this->top_--;
    }
    void push(const T &val)
    {
        if (this->full())
        {
            this->expend();
        }
        this->stack_[this->top_++] = val;
    }

private:
    void expend()
    {
        this->size_ *= 2;
        T *tmp = new T[this->size_];
        for (int i = 0; i < this->top_; i++)
        {
            tmp[i] = this->stack_[i];
        }
        delete[] stack_;
        this->stack_ = tmp;
    }

    T *stack_;
    int top_;
    int size_;
};

int main() {
    seqStack<int> s1(5);
    s1.push(1);
    s1.push(2);
    s1.push(2);
    s1.push(2);
    s1.push(2);
    s1.push(2);
    s1.push(2);
    s1.push(2);
    s1.push(2);
    s1.push(2);
    s1.push(2);
    s1.push(2);
}